#!/usr/bin/env bash
: C编译并运行

if [ $# == 0 ];then
    echo "没有带参数";
    file_name="代码完善";
else
    echo "带了$#个参数";
    file_name="$1";
fi

: 先删除c.out
if [ -f "c.out" ];then
  rm c.out
  echo "~~ c.out ~~"
else
  echo "~~ 初次编译c ~~"
fi

echo "\n -------- 开始编译 ----------"

g++ "$file_name" -o c.out

echo "\n---- 运行: $file_name ----\n"

./c.out
